﻿using Autofac;
using Autofac.Integration.Mvc;
using Common.Logging;
using Quartz;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using ZSZ.IService;

namespace ZSZ.AdminWeb.Jobs
{
    public class BossReportJob
    {
        private static ILog log = LogManager.GetLogger(typeof(BossReportJob));

        public void Execute(IJobExecutionContext context)
        {
            try
            {
                StringBuilder sbMsg = new StringBuilder();
                var container = AutofacDependencyResolver.Current.ApplicationContainer;
                using (container.BeginLifetimeScope())
                {
                    var cityService = container.Resolve<ICityService>();
                    var houseService = container.Resolve<IHouseService>();
                    foreach (var city in cityService.GetAll())
                    {
                        long count = houseService.GetTodayNewHouseCount(city.Id);
                        sbMsg.Append(city.Name).Append("新增房源的数量是：")
                            .Append(count).AppendLine();
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error("error", ex);
            }
        }
    }
}